//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_SYSTEM_BASE_ENUMERATOR_H
#define NATIVE_SYSTEM_BASE_ENUMERATOR_H

#ifndef NATIVE_SYSTEM_BASE_OBJECT_H
#include "System/Base/Object.h"
#endif
#ifndef NATIVE_SYSTEM_BASE_EQUALTO_H
#include "System/Base/EqualTo.h"
#endif

namespace Native { namespace System
{
    //****************************************************************************************************************//
    //Enumerator
    //
    //****************************************************************************************************************//
    template<typename _TEnum>
    class NATIVE_LIBRARY_EXPORT Enumerator :
        public CObject,
        public IEqualTo<Enumerator<_TEnum>>
    {
        NATIVE_DECLARE_OBJECT;

        NATIVE_REDEFINE(public, _TEnum, TEnum, T_ENUM);
        NATIVE_REDEFINE(public, Enumerator<TEnum>, Class, CLASS);
        
        NATIVE_DECLARE_PROPERTY(public, public, TEnum, Value, _value);

    public:
        Enumerator() :
            _value((TEnum)0)
        {};

        Enumerator(CLASS& that) :
            CObject(that),
            _value(that._value)
        {};

        Enumerator(CLASS&& that) :
            CObject(that),
            _value(that._value)
        {};

        Enumerator(TEnum value) :
            _value(value)
        {};

    public:
        //Convert to a corresponding wstring
        virtual wstring ToString() const
        {
            return UNumeric::ToString(_value);
        };
        
        virtual bool operator==(CLASS& rvalue) const
        {
            return _value == rvalue._value;
        };

        virtual bool operator!=(CLASS& rvalue) const
        {
            return !operator==(rvalue);
        };

        CLASS& operator=(CLASS& rvalue)
        {
            _value = rvalue._value;

            return *this;
        };

        CLASS& operator=(TEnum rvalue)
        {
            _value = rvalue;

            return *this;
        };
    };
}}

#endif